define([
    'jquery',
    'underscore',
    'backbone',
    'views/service/item',
    'iscroll'
], function ($, _, Backbone, ServiceListItemView) {
    var ServiceListView = Backbone.View.extend({

        tagName:'ul',

        initialize:function () {
            this.model.bind("reset", this.render, this);
            var self = this;
            this.model.bind("add", function (service) {
                $(self.el).prepend(new ServiceListItemView({model:service}).render().el);
            });
        },

        render:function (eventName) {
            _.each(this.model.models, function (service) {
                $(this.el).prepend(new ServiceListItemView({model:service}).render().el);
            }, this);
            return this;
        },
        scrollRender:function(){
            this.scrollNav = new iScroll('navWrapper');
            this.scrollContent = new iScroll('contentWrapper');
        }

    });
    return ServiceListView;
});

